



import bpy
import 全局控制.Node.节点和插座基类.bl_节点基类 as 基类
import pdb


'''class C_SN_容器_输入节点(bpy.types.NodeGroupInput, 基类.C_SN_基类):
	bl_label = '容器_输入'
	bl_dname = 'bl_node_容器输入'
	
	def init(self, context):
		super(C_SN_容器_输入节点, self).f_init(context)

	def f_update(self, 是否向下传递=False, input插座=None):
		print()
		pass

class C_SN_容器_输出节点(bpy.types.NodeGroupOutput, 基类.C_SN_基类):
	bl_label = '容器_输出'
	bl_dname = 'bl_node_容器输出'
	
	def init(self, context):
		super(C_SN_容器_输出节点, self).f_init(context)

	def f_update(self, 是否向下传递=False, input插座=None):
		pass'''


class C_SceneNode_容器(bpy.types.NodeCustomGroup, 基类.C_SN_基类): # 
	bl_label = '容器'
	bl_dname = 'bl_node_容器'
	bl_static_type = 'GROUP'

	#m_是否更新 = bpy.props.BoolProperty(name='更新内部节点')
	def init(self, context):
		super(C_SceneNode_容器, self).f_init(context, False)
		
		self.use_custom_color = True
		self.color = (0.5, 0.2, 0.5)
		self.node_tree = bpy.data.node_groups.new('容器', 'idname_场景对象操作节点树')
		self.node_tree.m_父节点树 = self.id_data
		#context.space_data.path.append(self.node_tree)
		#self.node_tree.inputs.new('bpy.types.NodeGroupInput', 'a')
		i_node = self.node_tree.nodes.new(type='NodeGroupInput')
		i_node.location.x = -300
		o_node = self.node_tree.nodes.new(type='NodeGroupOutput')
		o_node.location.x = 300
		
	def f_toCPP(self):
		self.node_tree
		
	#def f_init(self, context):
	#	super(C_SceneNode_容器, self).f_init(context)
	def draw_label(self):
		return '容器'
	#def draw_buttons(self, context, layout):
	#	layout.prop(self, 'm_运算类型')
	def draw_buttons_ext(self, context, layout):
		layout.prop(self, 'node_tree')

	def update(self):
		print('self.m_当前所在树 = ', type(self.node_tree), self.node_tree)

	

	def f_update(self):
		pass
		

	def f_进入子集(self):
		找到数量 = self.node_tree.nodes.find('Group Input')
		找到数量 = self.node_tree.nodes.find('Group Output')
		



class C_NODE_AddMenu_容器(bpy.types.Operator):
	bl_idname = 'node.global_node_container'
	bl_label = 'Add 容器节点'
	bl_options = {'REGISTER', 'UNDO'}
	
	def execute(operator, context):
		node = bpy.ops.node.add_node(type='C_SceneNode_容器', use_transform=True)
		#print('node = ', node)
		return {'FINISHED'}


classes = (
	#C_SN_容器_输入节点,
	#C_SN_容器_输出节点,

	C_SceneNode_容器,
	C_NODE_AddMenu_容器,
	
)


def register():
	bpy.types.NodeGroupInput.m_RootNode = None

	for c in classes:
		bpy.utils.register_class(c)
		
	
def unregister():
	for c in classes:
		bpy.utils.unregister_class(c)

	

